@extends('face.layout.main')

@section('content')
    <div class="col-sm-8 blog-main">

        <div class="alert alert-success alert-dismissable">
            <button type="button" class="close" data-dismiss="alert"
                    aria-hidden="true">
                &times;
            </button>
            搜索"{{$query}}" 结果:
        </div>

        @foreach($posts as $post)
            <div class="blog-post">
                <h1 class="blog-post-title"><a href="{{url('posts')}}/{{$post->id}}" >{{$post->title}}</a></h1>
                <p class="blog-post-meta">{{$post->updated_at->toFormattedDateString()}} by <a href="{{url('user/me')}}/{{$post->user_id}}">{{$post->user->name}}</a></p>

                <p>{!! str_limit($post->content) !!}</p>


                {{--post模型里 有hasMany对应的方法名__count    --}}
                <p class="blog-post-meta">赞 {{$post->zans_count}}  | 评论 {{$post->comments_count}}</p>
                {{--<p class="blog-post-meta">赞 {{$post->zans->count()}}  | 评论 {{$post->comments->count()}}</p>--}}
            </div>
        @endforeach
        {{$posts->links()}}
    </div><!-- /.blog-main -->
@endsection
